import { Directive,App } from 'vue';

// 输入控件去重指令
const trimInput: Directive = {
  mounted(el: HTMLInputElement) {
    
    const handler = (e: Event) => {
      const target = e.target as HTMLInputElement;
      target.value = target.value.trim();
    };
    el.addEventListener('input', handler);
  },
  unmounted(el: HTMLInputElement) {
    el.removeEventListener('input', (el as any).__handler__);
  }
};

const rejectDirective = (app: App<Element>) => {
    app.directive("trim",trimInput)
}
export default rejectDirective